﻿using Shop.RemoteModel.LogisticsConfig.Model;
using Shop.StoreGatewayModular.Interface;
using Shop.StoreGatewayModular.Model.LConfig;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Client;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Model;

namespace Shop.StoreGatewayModular.Api
{
    /// <summary>
    /// 物流配置
    /// </summary>
    [ApiRouteName("/shop/logistics/config/{name}")]
    internal class LogisticsConfigApi : ApiController
    {
        private readonly ILogisticsConfigService _Service;

        public LogisticsConfigApi (ILogisticsConfigService service)
        {
            this._Service = service;
        }
        /// <summary>
        /// 添加物流配置
        /// </summary>
        /// <param name="datum"></param>
        /// <returns></returns>
        public long Add (LConfigAdd datum)
        {
            return this._Service.Add(datum);
        }
        /// <summary>
        /// 计算物流费用
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public LogisticsPrice Calculate (CalculateLogisticsDto obj)
        {
            return this._Service.Calculate(obj);
        }
        /// <summary>
        /// 删除物流配置
        /// </summary>
        /// <param name="id"></param>
        public void Delete ([NumValidate("shop.logistics.config.id.error", 1)] long id)
        {
            this._Service.Delete(id);
        }
        /// <summary>
        /// 获取物流配置ID
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public LogisticsConfigDatum Get ([NumValidate("shop.logistics.config.id.error", 1)] long id)
        {
            return this._Service.Get(id);
        }
        /// <summary>
        /// 查询物流配置
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public LogisticsConfigDatum[] Gets (LQueryParam param)
        {
            return this._Service.Gets(param);
        }
        public PagingResult<LogisticsConfigDatum> Query (PagingParam<LQueryParam> param)
        {
            return this._Service.Query(param);
        }
        /// <summary>
        /// 修改物流配置
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public bool Set (LongParam<LogisticsConfigSet> param)
        {
            return this._Service.Set(param.Id, param.Value);
        }
        /// <summary>
        /// 设置是否启用
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public bool SetIsEnable (LongParam<bool> param)
        {
            return this._Service.SetIsEnable(param.Id, param.Value);
        }
    }
}
